package educational.cad.model;

import java.util.TreeSet;

/**
 * This class represents a wire entity, which consist of a segments.
 * 
 * @author Sergey Seroshtan
 * 
 */
public final class WirePath {

	public WirePath(TreeSet<WireSegment> segments) {

		if (segments == null) {
			throw new IllegalArgumentException("Wire segments are undefined");
		}
		if (segments.size() == 0) {
			throw new IllegalArgumentException("Wire path is undefined (no one segment)");
		}
		this.segments = segments;
	}

	public TreeSet<WireSegment> segments() {
		return segments;
	}

	private final TreeSet<WireSegment> segments;

	@Override
	public boolean equals(Object another) {
		return this.segments == ((WirePath)another).segments;
	}

	@Override
	public int hashCode() {
		int hash = 17;
		for (WireSegment segment : segments) {
			hash = 31 * hash + segment.hashCode();
		}
		return hash;
	}
	
	
}
